﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Cygnus.Web.PreContract
{
    public partial class TransformationFormLotusToPreContract : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string guid = Page.Request["guid"];
            if (string.IsNullOrEmpty(guid))
            {
                return;
            }

            //
            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            conn.ConnectionString = "UID=cygnus;Password=cygnus;Initial Catalog=Cygnus_UAT;Data Source=135.251.32.153";

            System.Data.SqlClient.SqlCommand com = new System.Data.SqlClient.SqlCommand();
            //com.CommandType = CommandType.StoredProcedure;
            com.Connection = conn;
            com.CommandText = string.Format(" exec SP_BLL_GetTransformationToPreContract '{0}' ", guid);


            System.Data.DataTable dt = new DataTable();
            System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(com);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (ds.Tables[0] != null)
                dt = ds.Tables[0]; 

            //BEGDC.Cygnus.BLL.Contract.IContractDomestic service = (BEGDC.Cygnus.BLL.Contract.IContractDomestic)BEGDC.Utility.Castle.AppContainer.Instance[BEGDC.Cygnus.BLL.ServicesKey.CONST_ContractDomestic_Service];
            //System.Data.DataTable dt = service.GetTransformationToPreContract(guid);

            Response.ContentType = "text/xml";

            dt.TableName = "record";


            System.IO.StringWriter writer = new System.IO.StringWriter();
            dt.WriteXml(writer, true);
            Response.Write(writer.ToString());
        }
    }
}
